package com.heima.user.controller.v1;

import com.heima.common.constants.UserConstants;
import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.user.dtos.AuthDto;
import com.heima.user.service.ApUserRealnameService;
import lombok.extern.slf4j.Slf4j;
import org.apache.catalina.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@RestController
@RequestMapping("/api/v1/auth")
public class ApUserRealnameController {
    @Autowired
    private ApUserRealnameService apUserRealnameService;

    /**
     * 条件分页查询用户审核列表
     *
     * @param dto
     * @return
     */
    @PostMapping("/list")
    public ResponseResult getAuthList(@RequestBody AuthDto dto) {
        log.info("用户审核列表:{}", dto);
        //调用vserice
        return apUserRealnameService.getAuthList(dto);
    }

    /**
     * 审核通过
     * @param authDto
     * @return
     */
    @PostMapping("/authPass")
    public ResponseResult authPass(@RequestBody AuthDto authDto) {
        log.info("用户审核通过:{}", authDto);

        return apUserRealnameService.authPass(authDto);
    }

    /**
     * 审核拒绝
     * @param dto
     * @return
     */
    @PostMapping("/authFail")
    public ResponseResult authFail(@RequestBody AuthDto dto) {
        log.info("驳回用户:{}", dto);
        //更新ap_user_realname表中对应的字段
        return apUserRealnameService.authFail(dto);
    }
}
